package com.kkb.factory3;

import com.kkb.factory2.Bmw;
import com.kkb.factory2.Car;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class Factory3 {

    public static Car getCarInstance(String str) throws Exception {
// 1 通过配置文件保存接口的实现类的信息，通过io流读取配置信息
        Properties properties = new Properties();
        properties.load(new FileInputStream("D:\\my03\\spring01\\src\\main\\resources\\car.properties"));
        String value = properties.getProperty(str);
        Car car = (Car) Class.forName(value).newInstance();
        return car;
    }
}
